
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
  
  
<!DOCTYPE html>
<html>
<head>

  <base href="${path}/pages/">
  <meta charset="utf-8">
  <title>影评天下首页</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layui/css/layui.css"  media="all">
  
  <style type="text/css">
  	a:link {
    	color: #37a;
    	text-decoration: none;
	}
	a:visited {
    	color: #669;
    	text-decoration: none;
	}
  </style>
  
</head>
<body>

<ul class="layui-nav" lay-filter="">
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon">&#xe68e;</i></a></li>
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon layui-icon-fire"></i> 影评天下</a></li>
  <li class="layui-nav-item" style="float:right" >
  	<a href="${path}/pages/register.jsp" id="register">注册</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
    <a href="${path}/pages/login.jsp" id="login">登录</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
  <a href="${path}/action/user/userCenter" id="user_center"></a>
  <dl class="layui-nav-child"> <!-- 二级菜单 -->
      <dd><a href="${path}/action/user/logout">登出</a></dd>
   </dl>
  </li>
  <li> <input type="hidden" value="${user.flag }" id="flag"></li>
</ul>



<hr class="layui-bg-gray">

<div class="layui-container">

	<div class="layui-tab">
  		<ul class="layui-tab-title">
    		<li class="layui-this">动作</li>
    		<li>喜剧</li>
    		<li>科幻</li>
    		<li>冒险</li>
    		<li>犯罪</li>
    		<li>剧情</li>
  		</ul>
  		<div class="layui-tab-content">
    		<div class="layui-tab-item layui-show">
    			<div style="margin:0 auto; "  class="layui-row" id="row1"></div>
    		</div>
    		<div class="layui-tab-item">
    			<div style="margin:0 auto; "  class="layui-row" id="row2"></div>
    		</div>
    		<div class="layui-tab-item">
    			<div style="margin:0 auto; "  class="layui-row" id="row3"></div>
    		</div>
    		<div class="layui-tab-item">
    			<div style="margin:0 auto; "  class="layui-row" id="row4"></div>
    		</div>
    		<div class="layui-tab-item">
    			<div style="margin:0 auto; "  class="layui-row" id="row5"></div>
    		</div>
    		<div class="layui-tab-item">
    			<div style="margin:0 auto; "  class="layui-row" id="row6"></div>
    		</div>
  		</div>
	</div>
	 
<hr class="layui-bg-gray">

		<div style="margin:0 auto; "  class="layui-row" id="col">
	
    		
    		
		</div>
		
<hr class="layui-bg-gray">

  		
	    



</div>



<script type="text/html" id="laytplContentMovie">
{{#  layui.each(d, function(index, item){ }}
    <div  class="layui-col-md2" style = "margin:0 auto; float:left;">
    		<a class="" href="${path}/action/movie/movieInfo?id={{ item.id }}" >
 	 			<div style="width:115px;margin:15px auto;" >
   					<img src="{{ item.moviePicture }}" alt="{{ item.movieName }}" data-x="1080" data-y="1512" style="width:115px;height:161px">
					<p style="width:115px; height:38.4px; color: #3377aa; margin:5px auto ;text-align:center;" >
  									{{ item.movieName }}	
  					<strong style="color:#e09015;">{{ item.overallRating }}</strong>
  					</p>
  				</div>
  			</a>
    </div>
{{# })  }}
</script>
  
  
<script type="text/html" id="laytplContentReview">
{{#  layui.each(d, function(index, item){ }}
	<hr class="layui-bg-gray">
    <div class="layui-row grid-demo">
	<div class="layui-col-md1" >
		<a href="${path}/action/movie/movieInfo?id={{ item.movie.id }}" ><img src="{{ item.movie.moviePicture }}"   data-x="1080" data-y="1512" style="display: inline; width: 68px; height: 94.94px"></a>
	</div>
	<div class="layui-col-md11">
		<h3>
			<a style="color: #669;text-decoration: none;" href="${path}/action/review/findById?id={{ item.id }}" class="">{{ item.title }}</a>
		</h3>
		<div class="layui-row-md1" style="color: #666; padding: 5px 0;">
                <a href="${path}/action/user/writerInfo?id={{ item.writer.id }}">{{ item.writer.userName }}</a> 评论
                <a href="${path}/action/movie/movieInfo?id={{ item.movie.id }}">{{ item.movie.movieName }}</a>
                <span class="rating" style="margin-left:10px">
					{{# for(var i=1; i<=item.rating; i++){ }} 
						<img src="../img/star_onmouseover.png" id="star${i}" width="16" height="16">
					{{# } }}
					{{# for(var i=1; i<=5-item.rating; i++){ }} 
						<img src="../img/star_hollow_hover.png" id="star${5-i}" width="16" height="16">
					{{# } }}                	

    			</span>
				<span style="margin-left:10px">{{ item.createTime }}</span>
        </div>
        <div class="layui-row-md3">
			<span>
				{{ item.content.substring(0,150) }}
			</span>
            <a href="${path}/action/review/findById?id={{ item.id }}">...(全文)</a>
        </div>
	</div>
</div>
{{# })  }}
</script>
  
<script type="text/javascript" src="../js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="../layui/layui.js"></script>
<script type="text/javascript">
  
    layui.use(['element','laypage','form','jquery','laytpl'],function(){
    	
      	var element = layui.element;
      	var laypage = layui.laypage;
      	var form = layui.form;
      	var laytpl = layui.laytpl;
      	var $ = layui.$;
      	
      	var flag=$('#flag').val();
      	
      	$.ajaxSettings.async = false;
      	$.getJSON('${path}/action/user/index1', function(data) {
      		if(data!=null){
      			flag=data.flag;
      		}
			
		});
      	$.ajaxSettings.async = true;
      
      	
      	var success=(flag=="");
      	if(success!=true){
      		
      		
      		
      		
              	 $("#user_center").html("个人中心");
              	 $("#login").html("");
              	 $("#register").html("");
              	 
              	

          	}else{
          		$("#user_center").html("");
          	 	$("#login").html("登录");
          	 	$("#register").html("注册");
          	}
          	
      	
      	
      	
      	laypage.render({
        	elem: 'demo',
        	count: 70
      	});
      	
      	
      	
      	//var typeId = $('#typeId').val(); 
      	//alert(typeId);
		$.getJSON('${path}/action/movie/findByType', {typeId:1}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row1").html (html);
		      });
		});
		
		$.getJSON('${path}/action/movie/findByType', {typeId:2}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row2").html (html);
		      });
		});
		
		$.getJSON('${path}/action/movie/findByType', {typeId:3}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row3").html (html);
		      });
		});
		
		$.getJSON('${path}/action/movie/findByType', {typeId:4}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row4").html (html);
		      });
		});
		
		$.getJSON('${path}/action/movie/findByType', {typeId:5}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row5").html (html);
		      });
		});
		
		$.getJSON('${path}/action/movie/findByType', {typeId:6}, function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentMovie').html();
				
			laytpl(tpl).render(data, function(html){
					
		      	$("#row6").html (html);
		      });
		});
		
		
			
		$.getJSON('${path}/action/review/findAll', function(data) {
			//alert(JSON.stringify(data));
			var tpl = $('#laytplContentReview').html();
		      	
		      laytpl(tpl).render(data, function(html){
		      		
		      	$("#col").html (html);
		      });
		});
   
    })   	
    
</script>

</body>
</html>